package com.eric.pageobject;

import static org.testng.Assert.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class Page {

	protected WebDriver driver;
	//protected String baseUrl;

	public Page(WebDriver driver) {
		this.driver = driver;
	}

	protected void assertThatTheTitleIsCorrect(String title) {
		assertEquals(driver.getTitle(), title);
	}

	protected void assertThatTheTitleIsNotCorrect(String title) {
		assertNotEquals(driver.getTitle(), title);
	}

	protected void openUrl(String url) {
		driver.get(url + "/");
	}

	protected void assertThatElementExistsOnPage(By by) {
		driver.findElement(by);
	}

	protected void click(By by) {
		driver.findElement(by).click();
	}

	protected void insertText(By by, String text) {
		WebElement element = driver.findElement(by);
		element.clear();
		element.sendKeys(text);
	}

}